//package com.whut.configuration;
//
//import org.aspectj.lang.JoinPoint;
//import org.aspectj.lang.annotation.*;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.stereotype.Component;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.context.request.ServletRequestAttributes;
//
//
//import javax.servlet.http.HttpServletRequest;
//
///**
// * @author ：xiaojun
// * @date ：Created in 2021/3/30 16:11
// * @description：日志切面类
// * @modified By：
// * @version: $
// */
//@Aspect
//@Component
//public class AopLog {
//    private Logger logger=LoggerFactory.getLogger(this.getClass());
//    ThreadLocal<Long> startTime=new ThreadLocal<>();
//
//    @Pointcut("execution(public * com.whut..*.*(..))")
//    public void aopWebLog(){}
//
//    @Before("aopWebLog()")
//    public void doBefore(JoinPoint joinPoint) throws Throwable{
//        startTime.set(System.currentTimeMillis());
//        ServletRequestAttributes attributes=(ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
//        HttpServletRequest request=attributes.getRequest();
//
//        logger.info("url:"+request.getRequestURL().toString());
//        logger.info("http method:"+request.getMethod());
//        logger.info("ip地址："+request.getRemoteAddr());
//        logger.info("类方法："+joinPoint.getSignature().getDeclaringTypeName()+"."+joinPoint.getSignature().getName());
//        logger.info("参数："+request.getQueryString());
//    }
//
//    @AfterReturning(pointcut = "aopWebLog()",returning = "retObject")
//    public void doAfterReturning(Object retObject) throws Throwable{
//        logger.info("应答值："+retObject);
//        logger.info("费时："+(System.currentTimeMillis()-startTime.get()));
//    }
//
//    @AfterThrowing(pointcut = "aopWebLog()",throwing = "ex")
//    public void addAfterThrowingLogger(JoinPoint joinPoint,Exception ex){
//        logger.error("异常：",ex);
//    }
//}
